From: Owen W. Taylor Date: Sat, 24 Apr 2010 13:41:03 +0000 (-0400) Subject: Make getting the environment from gnome-session more robust X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~10123 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=c4406d4acee44865ed23c765e5f0e659d97263e7;p=gnome-shell.git Make getting the environment from gnome-session more robust readlink() on /proc//exe can have results like: /usr/bin/gnome-keyring-daemon.#prelink#.5DFZsF (deleted) /usr/bin/gnome-session (deleted) To find gnome-session in a more robust way, read /proc//cmdline instead. https://bugzilla.gnome.org/show_bug.cgi?id=616706 --- diff --git a/src/gnome-shell.in b/src/gnome-shell.in index 27f7b0df0..0cb6db71c 100644 --- a/src/gnome-shell.in +++ b/src/gnome-shell.in @@ -37,10 +37,15 @@ def get_running_session_environs(): if not stat.st_uid == myuid: continue try: - exe = os.readlink(piddir + '/exe') - except OSError, e: + f = open(piddir + "/cmdline") + command = f.read() + f.close() + except IOError, e: continue - if os.path.basename(exe) != 'gnome-session': + # /proc/cmdline is separated and terminated by NULs + command = command.split("\x00")[0] + command = os.path.basename(command) + if command != 'gnome-session': continue try: f = open(os.path.join(piddir, 'environ'))